package controller

import (
	"encoding/json"
	"net/http"
)

const CodeSuccess = 0
const CodeError = -1

type JsonResponse struct {
	Code    int         `json:"code"`
	Data    interface{} `json:"data"`
	Message string      `json:"message"`
}

func RenderJsonResponse(rw http.ResponseWriter, res *JsonResponse) {
	rw.Header().Set("Content-type", "application/json")
	resByte, _ := json.Marshal(res)
	rw.Write(resByte)
}
